<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib uri="/WEB-INF/displaytag-el-12.tld" prefix="display" %>
<div id="FullContent">
	<h2>Projeto: ${project.name }</h2>
	<br/>
	Atividades
	<br/><br/>
	<display:table name="activities"
			requestURI="viewProjectActivities.action?projectCode=${project.code}"
			id="activity"
			pagesize="10">
	
		<display:column title="Nome" width="30%">
				${activity.name }</a>
		</display:column>
		
		<display:column title="Iniciar" width="5%" align="left">
			<div id="divImgAssociate_${activity.code }">
				<img src="<s:url value="/img/play-button.jpg"/>" width="20" height="21" style="cursor: pointer" 
					onclick="associateActivity(${activity.code });" id="imgAssociate_${activity.code }"/>
			</div>
		</display:column>

	</display:table>
	
</div>

<script>
	var projectCode = ${project.code}
	var activityCode = 0;	
	function associateActivity(actCode){
		activityCode = actCode;
		ManageProjectDwrAction.associateActivityToProject(actCode, projectCode, processResult);
	}
	
	function processResult(data){
		var divImgAssociate = document.getElementById("divImgAssociate_" + activityCode);
		var imgAssociate = document.getElementById("imgAssociate_" + activityCode);
		divImgAssociate.removeChild(imgAssociate);
		var newImg = document.createElement("img");
		if(data == true){
			newImg.setAttribute("src", "<s:url value="/img/ic_aceitar.gif"/>");
		}else{
			newImg.setAttribute("src", "<s:url value="/img/error.png"/>");
			newImg.setAttribute("width", "17");
			newImg.setAttribute("height", "17");
		}
		newImg.setAttribute("id", "imgAssociate_" + activityCode);
		divImgAssociate.appendChild(newImg);
	}
</script>
</html>
